home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 1.3 KB | 59 lines | [TEXT/CWIE] |
- // BufferOf.h
-
- #ifndef BufferOf_h
- #define BufferOf_h
-
- #ifndef ArrayOf_h
- #include "ArrayOf.h"
- #endif
-
- template < class Element > class ConstBufferOf;
-
- template < class Element >
- class BufferOf
- {
- typedef ArrayOf<Element> ArrayType;
- typedef ConstArrayOf<Element> ConstArrayType;
-
- typedef BufferOf<Element> BufferType;
- typedef ConstBufferOf<Element> ConstBufferType;
-
- private:
- ArrayType space;
- uint32 mark;
-
- // not implemented:
- BufferOf( const BufferType& );
- void operator=( const BufferType& );
-
- public:
- BufferOf( ArrayType );
-
- void Reset() { mark = 0; }
- void Reset( ArrayType );
-
- inline void AdvanceMark( uint32 amount );
-
- ConstArrayType Used() const { return space.Head( mark ); }
- ArrayType Unused() const { return space.Tail( mark ); }
-
- uint32 TotalLength() const { return space.Length(); }
- uint32 UsedLength() const { return mark; }
- uint32 UnusedLength() const { return space.Length() - mark; }
-
- bool IsEmpty() const { return mark == 0; }
- bool IsFull() const { return mark >= space.Length(); }
-
- void operator<<( ConstArrayType );
- void operator<<( ConstBufferType& );
- };
-
- template < class Element >
- inline void BufferOf<Element>::AdvanceMark( uint32 amount )
- {
- Assert( amount <= UnusedLength() );
- mark += amount;
- }
-
- #endif
-